<template  >

  <a-popover placement="bottomRight" >
    <template #content>
      <div class="mb-10"  @click="totalTvScreen(1)" style="cursor:pointer;">{{ $t('other.smartFactoryDataKanban') }} </div>
      <div @click="totalTvScreen(3)"  style="cursor:pointer;">{{ $t('other.smartFactoryDataGroupKanban') }}</div>
      <div class="mt-10" @click="totalTvScreen(4)" v-if="show4"  style="cursor:pointer;">{{ $t('other.productionQualitySignage') }}</div>
    </template>
    <span class="tvScreen" ></span>
  </a-popover>
</template>

<script>
import { getLocalStorage } from '@/utils'
import { mapState } from "vuex"
export default {
  data () {
    return {
      show4: false,
      connectionIdx: 0,
      messageIdx: 0,
      datas: {
        url: ''
      }
    }
  },
  computed: {
    ...mapState({
      configuration: (state) => state.setting.configuration
    })
  },
  watch: {
    configuration: {
      handler() {
        this.changStatus()
      },
      deep: true,
      immediate: true,
    },
  },
  methods: {
    totalTvScreen (val) {
      let currentLine = localStorage.getItem("currentLine") ? JSON.parse(localStorage.getItem("currentLine")) : {}
      let locale = localStorage.getItem("locale") || 'zh-cn'
      let protocol = window.location.protocol
      let hostname = window.location.hostname
      let url = ''
      if (val == 1){
        url = `${protocol}//${hostname}:8055/screen1?lang=${locale}`
      }
      if (val == 2){
        url = `${protocol}//${hostname}:8055/screen2?lineNo=${currentLine.lineNo}&lang=${locale}`
      }
      if(val == 3) {
        url = `${protocol}//${hostname}:8055/screen3?lineNo=${currentLine.lineNo}&lang=${locale}`
      }
      if(val == 4) {
        url = `${protocol}//${hostname}:8055/screen4?lineNo=${currentLine.lineNo}&lang=${locale}`
      }
      window.open(url, '_blank')
    } ,
    changStatus() {
      this.show4 = this.configuration ? this.configuration.inspectionConfig != 1 : getLocalStorage('configuration')?.inspectionConfig !=1
    }
  },
  async created () {
    this.changStatus()
  }
}
</script>